package yja.gzw.app.model.utils

import yja.gzw.app.model.api.Apiserves
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit



class HttpUtils private constructor(){
    companion object{
        val httpwang: HttpUtils by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){

            HttpUtils()
        }
    }


    val retrofit=Retrofit.Builder()
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .baseUrl("http://117ai.32.hzgqapp.com/")
        .client(
            OkHttpClient.Builder()
                // .addInterceptor(RetryInterceptor())
                .addInterceptor(HttpLoggingInterceptor().apply {
                    level= HttpLoggingInterceptor.Level.BODY

                })
                .readTimeout(60, TimeUnit.SECONDS)
                .connectTimeout(60, TimeUnit.SECONDS)
                .build()

        ).build()

    val apiservsi=retrofit.create<Apiserves>()





}